package com.example.gomi.intelligentcitypipe.DAO;

import android.text.StaticLayout;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.types.LongObjectType;
import com.j256.ormlite.table.DatabaseTable;

import java.util.Date;

/**
 * Created by GoMi on 16/6/30.
 */
@DatabaseTable(tableName = "pipeinfo")
public class PipeInfo {

    @DatabaseField(generatedId = true)
    private int id;

    @DatabaseField(useGetSet = true, columnName = "pipeid", unique = true)
    private long pipeid;

    @DatabaseField(useGetSet = true, columnName = "frequence")
    private String frequence;

    @DatabaseField(useGetSet = true, columnName = "type")
    private int type;

    @DatabaseField(useGetSet = true, columnName = "year")
    private int year;

    @DatabaseField(useGetSet = true, columnName = "month")
    private int month;

    @DatabaseField(useGetSet = true, columnName = "day")
    private int day;

    @DatabaseField(useGetSet = true, columnName = "hour")
    private int hour;

    @DatabaseField(useGetSet = true, columnName = "minute")
    private int minute;

    @DatabaseField(useGetSet = true, columnName = "remark")
    private String remark;

    @DatabaseField(useGetSet = true, columnName = "company")
    private int company;

    @DatabaseField(useGetSet = true, columnName = "discription")
    private String discription;

    @DatabaseField(useGetSet = true, columnName = "jobid")
    private int jobid;

    @DatabaseField(useGetSet = true, columnName = "latitude")
    private double latitude;

    @DatabaseField(useGetSet = true, columnName = "longitude")
    private double longitude;

    @DatabaseField(useGetSet = true, columnName = "batteryLevel")
    private int batteryLevel;


    @DatabaseField(useGetSet = true, columnName = "temperature")
    private double temperature;

    @DatabaseField(useGetSet = true, columnName = "humidity")
    private double humidity;

    private static long[] CARD_ID = {
            56073744907L,//FF 0D0E41720B 0E7800C7
            56074732295L,//FF 0D0E508307 0E2A0079
            56073839371L,//FF 0D0E42E30B 0E10003D
            //236589063,//0x00, 0x0e, 0x1a, 0x10, 0x07,
            //239264523,//0x00, 0x0E, 0x42, 0xE3, 0x0B,
            //239702795,//0x00, 0x0E, 0x49, 0x93, 0x0B,
            //240771592,//0x00, 0x0E, 0x59, 0xE2, 0x08,

    };

    public PipeInfo() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public long getPipeid() {
        return pipeid;
    }

    public void setPipeid(long pipeid) {
        this.pipeid = pipeid;
    }

    public String getFrequence() {
        return frequence;
    }

    public void setFrequence(String frequence) {
        this.frequence = frequence;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getCompany() {
        return company;
    }

    public void setCompany(int company) {
        this.company = company;
    }

    public String getDiscription() {
        return discription;
    }

    public void setDiscription(String discription) {
        this.discription = discription;
    }

    public int getJobid() {
        return jobid;
    }

    public void setJobid(int jobid) {
        this.jobid = jobid;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public int getBatteryLevel() {
        return batteryLevel;
    }

    public void setBatteryLevel(int batteryLevel) {
        this.batteryLevel = batteryLevel;
    }

    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    public double getHumidity() {
        return humidity;
    }

    public void setHumidity(double humidity) {
        this.humidity = humidity;
    }

    public String toString() {
        String result = "";
        result =  "序号：" + Integer.toString(id) + "\n" +
                        "EPC编码：" + Long.toString(pipeid) + "\n"
                        + "管道类型：" + convertType(type) + "\n"
                        + "填埋日期：" + Integer.toString(year) + "-" + Integer.toString(month) + "-" + Integer.toString(day) + "  "
                        + Integer.toString(hour) + ":" + Integer.toString(minute) + "\n"
                        +"温度："+String.format("%.2f°C", temperature)+"\n"
                        +"湿度："+String.format("%.2f%%", humidity)+"\n";
        return result;
    }

    public static String convertType(int type) {
        return "自来水管";
    }

    public static String convertCompany(int company) {
        return "江汉大学智慧城市项目组";
    }

    public static String convertJobID(int jobid) {
        return "毛五星";
    }

    public boolean checkPipeID() {

        for (int i = 0; i < CARD_ID.length; i++) {
            if (pipeid == CARD_ID[i]) {
                return true;
            }
        }
        return false;
        //return true;
    }


}
